﻿namespace Cmn
{
    using System;

    public class Valid
    {
        public static bool isDateTime(string input)
        {
            string op = @"^(?=\d)(?:(?!(?:1582(?:\.|-|\/)10(?:\.|-|\/)(?:0?[5-9]|1[0-4]))|(?:1752(?:\.|-|\/)0?9(?:\.|-|\/)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\.|-|\/)(?:29|30))))(\d{4})([-\/.])(0?\d|1[012])\2((?!00)[012]?\d|3[01])(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]?\d|2[0-3])(?::[0-5]\d){1,2})?$";
            return Str.isMatch(op, input);
        }

        public static bool isEmail(string input)
        {
            string op = @"^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$";
            return Str.isMatch(op, input);
        }

        public static bool IsInt(string input)
        {
            string op = "^[0-9]*[1-9][0-9]*$";
            return Str.isMatch(op, input);
        }

        public static bool isIP(string input)
        {
            string op = @"(\d+)\.(\d+)\.(\d+)\.(\d+)";
            return Str.isMatch(op, input);
        }

        public static bool isNumber(string strNumber)
        {
            string op = @"^([0-9])[0-9]*(\.\w*)?$";
            return Str.isMatch(op, strNumber);
        }

        public static bool IsNumeric(string input)
        {
            return false;
        }

        public static bool isSSN(string input)
        {
            string op = @"\d{18}|\d{15}";
            return Str.isMatch(op, input);
        }

        public static bool isTime(string input)
        {
            string op = @"^([0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$";
            return Str.isMatch(op, input);
        }

        public static bool isUrl(string input)
        {
            string op = @"^http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";
            return Str.isMatch(op, input);
        }

        public static bool isUsableUserName(string input)
        {
            string op = "^[a-zA-Z0-9_]+$";
            return Str.isMatch(op, input);
        }

        public static bool isZip(string input)
        {
            string op = @"\d{6}";
            return Str.isMatch(op, input);
        }
    }
}

